﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BUS;
using Entity;

public partial class DangNhap : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    Nhan_Vien nv = new Nhan_Vien();

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        nv = NhanVienBUS.DangNhap(Login1.UserName, Login1.Password);
        if (nv != null)
        {
            e.Authenticated = true;
            Session["UserName"] = Login1.UserName;
            Session["QuanLy"] = nv.QuanLy;
            if (nv.QuanLy)
                Response.Redirect("Admin/QuanLy.aspx");
            else
                Response.Redirect("User/NhanVien.aspx");
        }
    }
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        Session["UserName"] = Login1.UserName;
        Session["QuanLy"] = nv.QuanLy;
    }
}
